/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import com.lowagie.text.Image;
import dao.*;
import java.awt.event.KeyEvent;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.MaskFormatter;
import model.*;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.view.JasperViewer;
import org.hibernate.dialect.Sybase11Dialect;
import sun.security.x509.AttributeNameEnumeration;

/**
 * CADASTRO PADRÃO
 *
 * @author JONATAS
 *
 *
 */
public class ProjetoFrame extends javax.swing.JFrame {

    /**
     * Creates new form FamiliaFrame
     */
    public ProjetoFrame() {
        initComponents();
        setStatusInicial();

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel29 = new javax.swing.JLabel();
        btnExlcuirProjeto = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnSalvar = new javax.swing.JButton();
        TabDimensoes = new javax.swing.JTabbedPane();
        jPanel5 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        tbDataProjeto = new javax.swing.JFormattedTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        ctDescricao = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        tbCliente = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        tbDataInicioPrev = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        tbDataFimPrev = new javax.swing.JFormattedTextField();
        tbEnderecoCliente = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tbCodigo = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        tbStatus = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        tbDataInicio = new javax.swing.JFormattedTextField();
        jLabel31 = new javax.swing.JLabel();
        tbDataConclusao = new javax.swing.JFormattedTextField();
        jLabel32 = new javax.swing.JLabel();
        lbProjetoPrincipal = new javax.swing.JLabel();
        lbCodigoProjetoPrincipal = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        tbCPF = new javax.swing.JTextField();
        jPanel9 = new javax.swing.JPanel();
        tbLogradouroInst = new javax.swing.JTextField();
        tbComplementoInst = new javax.swing.JTextField();
        tbBairroInst = new javax.swing.JTextField();
        tbCepInst = new javax.swing.JFormattedTextField();
        tbCidadeInst = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        tbEstadoConstr = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        tbPaisConstr = new javax.swing.JTextField();
        btnCopiarEnd = new javax.swing.JButton();
        tbCodigoCidade = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        btnIniciarConstr = new javax.swing.JButton();
        btnConcluirConstr = new javax.swing.JButton();
        btnCopiarProjeto = new javax.swing.JButton();
        btnCriarComplemento = new javax.swing.JButton();
        btnReativar = new javax.swing.JButton();
        btnImprimir = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        tbLargura = new javax.swing.JFormattedTextField();
        tbAltura = new javax.swing.JFormattedTextField();
        tbComprimento = new javax.swing.JFormattedTextField();
        jPanel12 = new javax.swing.JPanel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        tbPerimetro = new javax.swing.JTextField();
        tbArea = new javax.swing.JTextField();
        jPanel14 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jLabel45 = new javax.swing.JLabel();
        btnExlcuirProdutoComp1 = new javax.swing.JButton();
        btnAddProdutos = new javax.swing.JButton();
        jLabel46 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        tbValorTotal = new javax.swing.JFormattedTextField();
        jButton1 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        lbFoto = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tbEnderecoImg = new javax.swing.JTextField();
        btnImagem = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        tbNomeImagem = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        tbDescricaoImagem = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        btnAddImagem = new javax.swing.JButton();
        jPanelEncerramento = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        ctMotivoEncerra = new javax.swing.JTextArea();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        tbNomeUsuarioFim = new javax.swing.JTextField();
        tbDataEncerraTab4 = new javax.swing.JFormattedTextField();
        jPanel11 = new javax.swing.JPanel();
        jLabel36 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        ctObsInicio = new javax.swing.JTextArea();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        tbNomeUsuarioInicio = new javax.swing.JTextField();
        tbDataInicioTab4 = new javax.swing.JFormattedTextField();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jLabel42 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem9 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        Relatório = new javax.swing.JMenu();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();

        jLabel29.setText("jLabel29");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Projetos");
        setMinimumSize(new java.awt.Dimension(923, 584));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
            public void windowActivated(java.awt.event.WindowEvent evt) {
                buscar(evt);
            }
        });

        btnExlcuirProjeto.setText("Deletar");
        btnExlcuirProjeto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExlcuirProjetoActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnSalvar.setText("Salvar");
        btnSalvar.setName("");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        TabDimensoes.setMinimumSize(new java.awt.Dimension(901, 500));

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Data Registro do Projeto:");

        try {
            tbDataProjeto.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        ctDescricao.setColumns(20);
        ctDescricao.setLineWrap(true);
        ctDescricao.setRows(5);
        ctDescricao.setWrapStyleWord(true);
        ctDescricao.setNextFocusableComponent(tbCPF);
        ctDescricao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                ctDescricaoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                ctDescricaoKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                ctDescricaoKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(ctDescricao);

        jLabel2.setText("Descrição:");

        jLabel5.setText("Cliente:");

        tbCliente.setEditable(false);

        jLabel6.setText("Data prevista para início da construção:");

        try {
            tbDataInicioPrev.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel7.setText("Data prevista para término:");

        try {
            tbDataFimPrev.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        tbEnderecoCliente.setEnabled(false);
        tbEnderecoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbEnderecoClienteActionPerformed(evt);
            }
        });

        jLabel8.setText("Endereço:");

        tbCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbCodigoActionPerformed(evt);
            }
        });
        tbCodigo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbCodigoFocusLost(evt);
            }
        });
        tbCodigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbCodigoKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbCodigoKeyTyped(evt);
            }
        });

        jLabel14.setText("Código:");

        jLabel30.setText("Status:");

        try {
            tbDataInicio.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel31.setText("Data início da construção:");

        try {
            tbDataConclusao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel32.setText("Data da conclusão:");

        lbProjetoPrincipal.setText("Projeto Principal");

        jLabel28.setText("CPF/CNPJ:");

        tbCPF.setNextFocusableComponent(tbDataInicioPrev);
        tbCPF.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbCPFFocusLost(evt);
            }
        });
        tbCPF.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbCPFKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbCodigo)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel30))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbDataProjeto, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(41, 41, 41))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel8)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(tbDataInicioPrev, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tbDataInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel31))
                                .addGap(36, 36, 36)
                                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel32)
                                    .addComponent(tbDataConclusao, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel7)
                                    .addComponent(tbDataFimPrev, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(lbProjetoPrincipal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbCodigoProjetoPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1)
                            .addComponent(tbEnderecoCliente))
                        .addContainerGap())
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel28)
                            .addComponent(tbCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(tbCliente))
                        .addContainerGap())))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lbProjetoPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbCodigoProjetoPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel14)
                    .addComponent(jLabel30))
                .addGap(3, 3, 3)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbDataProjeto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addGap(3, 3, 3)
                .addComponent(jScrollPane1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel28)
                        .addGap(1, 1, 1)
                        .addComponent(tbCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(4, 4, 4)
                        .addComponent(tbCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10)
                .addComponent(jLabel8)
                .addGap(5, 5, 5)
                .addComponent(tbEnderecoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbDataInicioPrev, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbDataFimPrev, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel31)
                    .addComponent(jLabel32))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbDataInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbDataConclusao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        try {
            tbCepInst.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tbCepInst.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbCepInstFocusLost(evt);
            }
        });

        tbCidadeInst.setEnabled(false);
        tbCidadeInst.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbCidadeInstFocusLost(evt);
            }
        });

        jLabel21.setText("Logradouro:");

        jLabel22.setText("Complemento:");

        jLabel23.setText("Bairro:");

        jLabel24.setText("CEP:");

        jLabel25.setText("Cidade:");

        jLabel26.setText("Estado:");

        tbEstadoConstr.setEnabled(false);

        jLabel27.setText("País:");

        tbPaisConstr.setEnabled(false);

        btnCopiarEnd.setText("Copiar endereço do Cliente");
        btnCopiarEnd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCopiarEndActionPerformed(evt);
            }
        });

        tbCodigoCidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbCodigoCidadeFocusLost(evt);
            }
        });
        tbCodigoCidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbCodigoCidadeKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tbBairroInst, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(tbComplementoInst)
                    .addComponent(tbLogradouroInst)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addGap(0, 197, Short.MAX_VALUE)
                        .addComponent(btnCopiarEnd))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbCepInst, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel24))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(tbCodigoCidade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tbCidadeInst, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel25)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22)
                            .addComponent(jLabel23))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbEstadoConstr, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel26))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel27)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(tbPaisConstr))))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbLogradouroInst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel22)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbComplementoInst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel23)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbBairroInst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel24)
                        .addGap(1, 1, 1)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tbCepInst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tbCodigoCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tbCidadeInst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel26)
                            .addComponent(jLabel27))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tbEstadoConstr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tbPaisConstr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel25))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCopiarEnd)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnIniciarConstr.setText("Iniciar Construção");
        btnIniciarConstr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIniciarConstrActionPerformed(evt);
            }
        });

        btnConcluirConstr.setText("Concluir");
        btnConcluirConstr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConcluirConstrActionPerformed(evt);
            }
        });

        btnCopiarProjeto.setText("Copiar este projeto");
        btnCopiarProjeto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCopiarProjetoActionPerformed(evt);
            }
        });

        btnCriarComplemento.setText("Criar Complemento");
        btnCriarComplemento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCriarComplementoActionPerformed(evt);
            }
        });

        btnReativar.setText("Reativar");
        btnReativar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReativarActionPerformed(evt);
            }
        });

        btnImprimir.setText("Imprimir");
        btnImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnIniciarConstr, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                    .addComponent(btnConcluirConstr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnReativar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnImprimir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnCriarComplemento, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnCopiarProjeto, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnIniciarConstr)
                    .addComponent(btnCopiarProjeto)
                    .addComponent(btnImprimir))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnConcluirConstr)
                    .addComponent(btnCriarComplemento)
                    .addComponent(btnReativar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel9.setText("Dados Iniciais:");

        jLabel20.setText("Endereço da construção da estufa:");

        jLabel13.setText("Ações:");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel20)
                            .addComponent(jLabel13))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        TabDimensoes.addTab("Dados iniciais do Projeto", jPanel5);

        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel33.setText("Largura:");

        jLabel34.setText("Altura:");

        jLabel35.setText("Comprimento:");

        tbLargura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));

        tbAltura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));

        tbComprimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        tbComprimento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbComprimentoFocusLost(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel33)
                            .addComponent(jLabel34)
                            .addComponent(jLabel35)
                            .addComponent(tbLargura, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(tbAltura)
                    .addComponent(tbComprimento))
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addComponent(jLabel33)
                .addGap(2, 2, 2)
                .addComponent(tbLargura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel34)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbAltura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel35)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(tbComprimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel12.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel40.setText("Perímetro:");

        jLabel41.setText("Área interior:");

        tbPerimetro.setEnabled(false);

        tbArea.setEnabled(false);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel40)
                    .addComponent(jLabel41)
                    .addComponent(tbPerimetro, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbArea, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addComponent(jLabel40)
                .addGap(2, 2, 2)
                .addComponent(tbPerimetro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel41)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel14.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Classe", "Familia", "Quantidade", "Unidade de Medida"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Integer.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, true, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setColumnSelectionAllowed(true);
        jScrollPane6.setViewportView(jTable2);
        jTable2.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        jLabel45.setText("Composição: ");

        btnExlcuirProdutoComp1.setText("Excluir Produto");
        btnExlcuirProdutoComp1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExlcuirProdutoComp1ActionPerformed(evt);
            }
        });

        btnAddProdutos.setText("Adicionar Produto");
        btnAddProdutos.setNextFocusableComponent(btnSalvar);
        btnAddProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddProdutosActionPerformed(evt);
            }
        });
        btnAddProdutos.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                btnAddProdutosFocusLost(evt);
            }
        });
        btnAddProdutos.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnAddProdutosKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                btnAddProdutosKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnExlcuirProdutoComp1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAddProdutos))
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 719, Short.MAX_VALUE)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jLabel45)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                .addComponent(jLabel45)
                .addGap(12, 12, 12)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 402, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnExlcuirProdutoComp1)
                    .addComponent(btnAddProdutos)))
        );

        jLabel46.setText("Dimensões:");

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setText("Valor Total:");

        tbValorTotal.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        tbValorTotal.setNextFocusableComponent(btnAddProdutos);
        tbValorTotal.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbValorTotalFocusLost(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(0, 46, Short.MAX_VALUE))
                    .addComponent(tbValorTotal))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbValorTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19))
        );

        jButton1.setText("Calcular");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel46)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jLabel46)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        TabDimensoes.addTab("Dimensões e Materiais Utilizados", jPanel4);

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lbFoto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbFoto.setText("Sem imagem selecionada");
        lbFoto.setToolTipText("");
        lbFoto.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        lbFoto.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lbFoto.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        lbFoto.setMaximumSize(new java.awt.Dimension(500, 500));
        lbFoto.setMinimumSize(new java.awt.Dimension(500, 500));

        jLabel4.setText("Imagem:");

        tbEnderecoImg.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbEnderecoImgFocusLost(evt);
            }
        });

        btnImagem.setText("Imagem...");
        btnImagem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImagemActionPerformed(evt);
            }
        });
        btnImagem.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                btnImagemFocusLost(evt);
            }
        });

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome Imagem", "Descrição", "Caminho Imagem"
            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTable1MousePressed(evt);
            }
        });
        jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTable1KeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTable1KeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTable1KeyTyped(evt);
            }
        });
        jScrollPane4.setViewportView(jTable1);

        jLabel10.setText("Endereço da Imagem:");

        jLabel11.setText("Nome da Imagem:");

        jLabel12.setText("Descrição da Imagem:");

        btnAddImagem.setText("Adicionar Imagem");
        btnAddImagem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddImagemActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel11)
                            .addComponent(jLabel10)
                            .addComponent(jLabel12)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                                .addComponent(tbDescricaoImagem)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnAddImagem))
                            .addComponent(tbNomeImagem)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                                .addComponent(tbEnderecoImg)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnImagem))
                            .addComponent(lbFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 377, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(lbFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tbEnderecoImg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnImagem))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tbNomeImagem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tbDescricaoImagem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnAddImagem)))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        TabDimensoes.addTab("Imagens do Projeto", jPanel6);

        jPanelEncerramento.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel17.setText("Motivo:");

        ctMotivoEncerra.setColumns(20);
        ctMotivoEncerra.setLineWrap(true);
        ctMotivoEncerra.setRows(5);
        ctMotivoEncerra.setWrapStyleWord(true);
        jScrollPane2.setViewportView(ctMotivoEncerra);

        jLabel15.setText("Informações do Encerramento:");

        jLabel16.setText("Data Encerramento:");

        jLabel19.setText("Usuário:");

        tbNomeUsuarioFim.setEnabled(false);

        try {
            tbDataEncerraTab4.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel17)
                                    .addComponent(jLabel15)
                                    .addComponent(jLabel16))
                                .addGap(0, 243, Short.MAX_VALUE))
                            .addComponent(tbNomeUsuarioFim))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(tbDataEncerraTab4, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel16)
                .addGap(5, 5, 5)
                .addComponent(tbDataEncerraTab4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbNomeUsuarioFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel36.setText("Motivo:");

        ctObsInicio.setColumns(20);
        ctObsInicio.setLineWrap(true);
        ctObsInicio.setRows(5);
        ctObsInicio.setWrapStyleWord(true);
        jScrollPane5.setViewportView(ctObsInicio);

        jLabel37.setText("Informações do início da construção:");

        jLabel38.setText("Data Início:");

        jLabel39.setText("Usuário:");

        tbNomeUsuarioInicio.setEnabled(false);

        try {
            tbDataInicioTab4.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane5)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel36)
                                    .addComponent(jLabel38)
                                    .addComponent(jLabel37))
                                .addGap(0, 171, Short.MAX_VALUE))
                            .addComponent(tbNomeUsuarioInicio))
                        .addContainerGap())
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel39)
                            .addComponent(tbDataInicioTab4, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel37)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel38)
                .addGap(5, 5, 5)
                .addComponent(tbDataInicioTab4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel36)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel39)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbNomeUsuarioInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanelEncerramentoLayout = new javax.swing.GroupLayout(jPanelEncerramento);
        jPanelEncerramento.setLayout(jPanelEncerramentoLayout);
        jPanelEncerramentoLayout.setHorizontalGroup(
            jPanelEncerramentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEncerramentoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanelEncerramentoLayout.setVerticalGroup(
            jPanelEncerramentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEncerramentoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEncerramentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        TabDimensoes.addTab("Informações Adicionais", jPanelEncerramento);

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Data", "Descrição da Alteração", "Situação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable3MouseClicked(evt);
            }
        });
        jScrollPane7.setViewportView(jTable3);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 870, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 431, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );

        TabDimensoes.addTab("Complementos", jPanel13);

        jLabel42.setText("jLabel42");

        jMenu1.setText("Cadastros");

        jMenuItem1.setText("Clientes");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem12.setText("Usuários");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem12);
        jMenu1.add(jSeparator3);

        jMenuItem2.setText("Casses");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem3.setText("Famílias");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem8.setText("Produtos");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem8);
        jMenu1.add(jSeparator1);

        jMenuItem9.setText("Localização");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem9);
        jMenu1.add(jSeparator2);

        jMenuItem4.setText("Sair");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Projetos");

        jMenuItem5.setText("Gerenciar Projetos");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuItem6.setText("Consultar Projetos");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuItem10.setText("Imprimir Documento");
        jMenu2.add(jMenuItem10);

        jMenuBar1.add(jMenu2);

        Relatório.setText("Relatórios");

        jMenuItem13.setText("Relatório de Classes/Famílias");
        Relatório.add(jMenuItem13);

        jMenuItem14.setText("Relatório de Materiais");
        Relatório.add(jMenuItem14);

        jMenuItem15.setText("Relatório de Projetos");
        Relatório.add(jMenuItem15);

        jMenuItem16.setText("Relatório de Clientes");
        Relatório.add(jMenuItem16);

        jMenuBar1.add(Relatório);

        jMenu4.setText("Sobre");
        jMenuBar1.add(jMenu4);

        jMenu3.setText("Sair");

        jMenuItem7.setText("Sair");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem7);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(TabDimensoes, javax.swing.GroupLayout.PREFERRED_SIZE, 899, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btnSalvar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnExlcuirProjeto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancelar)
                        .addGap(25, 25, 25))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TabDimensoes, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSalvar)
                    .addComponent(btnExlcuirProjeto)
                    .addComponent(btnCancelar))
                .addGap(18, 18, 18))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-941)/2, (screenSize.height-651)/2, 941, 651);
    }// </editor-fold>//GEN-END:initComponents

    private void setStatusInicial() {

        status = 'I';

        btnReativar.setEnabled(false);
        btnImprimir.setEnabled(false);
        btnExlcuirProjeto.setEnabled(false);
        btnCriarComplemento.setEnabled(false);
        btnConcluirConstr.setEnabled(false);
        btnExlcuirProjeto.setEnabled(false);
        btnIniciarConstr.setEnabled(false);
        btnCopiarProjeto.setEnabled(false);
        btnCopiarEnd.setEnabled(false);

        tbStatus.setText("Aberto");

        tbDataInicio.setText("");
        tbDataInicio.setEnabled(false);
        tbDataEncerraTab4.setText("");
        tbDataEncerraTab4.setEnabled(false);
        tbDataConclusao.setEnabled(false);
        tbDataConclusao.setText("");
        tbDataFimPrev.setText("");
        tbDataInicioPrev.setText("");
        tbStatus.setEnabled(false);

        ctMotivoEncerra.setText("");
        ctObsInicio.setText("");

        TabDimensoes.setEnabledAt(4, false);
        jPanelEncerramento.setVisible(false);
        tbCodigo.setEnabled(true);

        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        // System.out.println(sdf.format(new Date()));

        tbDataProjeto.setText(sdf.format(new Date()));

    }

    private void setStatusAlterar() {

        status = 'A';

        btnImprimir.setEnabled(true);
        btnExlcuirProjeto.setEnabled(true);
        //  TabDimensoes.setEnabledAt(4, true);
        btnCriarComplemento.setEnabled(true);
        btnCopiarEnd.setEnabled(true);
        btnConcluirConstr.setEnabled(true);
        btnExlcuirProjeto.setEnabled(true);
        btnIniciarConstr.setEnabled(true);
        btnCopiarProjeto.setEnabled(true);
        tbDataInicio.setEnabled(false);
    }

    private void limparCampos() {
        tbDataProjeto.setText("");
        tbBairroInst.setText("");
        tbEnderecoImg.setText("");
        tbCepInst.setText("");
        tbLogradouroInst.setText("");
        tbCidadeInst.setText("");
        tbEstadoConstr.setText("");
        tbCliente.setText("");
        tbCPF.setText("");
        tbEnderecoCliente.setText("");
        tbCodigoCidade.setText("");
        tbComplementoInst.setText("");
        //tbDataEncerra.setText("");
        tbDataFimPrev.setText("");
        tbDataInicioPrev.setText("");
        ctDescricao.setText("");
        tbNomeImagem.setText("");
        tbEnderecoImg.setText("");
        tbDescricaoImagem.setText("");
        tbCodigo.setText("");
        tbStatus.setText("");
        tbPaisConstr.setText("");
        tbDataInicio.setText("");
        tbDataInicioTab4.setText("");
        tbDataEncerraTab4.setText("");
        tbDataConclusao.setText("");
        tbPerimetro.setText("");
        tbArea.setText("");
        tbAltura.setText("");
        tbComprimento.setText("");
        tbLargura.setText("");
        carregarImagem(tbEnderecoImg.getText());

        lbProjetoPrincipal.setText("Projeto Principal");
        lbCodigoProjetoPrincipal.setText("");

        TabDimensoes.setSelectedIndex(0);

        DefaultTableModel modelo = (DefaultTableModel) jTable2.getModel();
        modelo.setNumRows(0);
        DefaultTableModel modelo1 = (DefaultTableModel) jTable1.getModel();
        modelo1.setNumRows(0);

    }

    private boolean verificaCamposNulos() {
        /*
         * if (tbDescricao.getText().isEmpty()) {
         * JOptionPane.showMessageDialog(null, "Campo descrição em branco!");
         * tbDescricao.requestFocus(); return false; } if
         * (cmbClasse.getSelectedIndex() == 0) {
         * JOptionPane.showMessageDialog(null, "Selecione uma classe!");
         * cmbClasse.requestFocus(); return false; } if
         * (cmbFamilia.getSelectedIndex() == 0) {
         * JOptionPane.showMessageDialog(null, "Selecione uma familia!");
         * cmbFamilia.requestFocus(); return false; } if
         * (cmbUnidadeMedida.getSelectedIndex() == 0) {
         * JOptionPane.showMessageDialog(null, "Selecione uma unidade de
         * medida!"); cmbUnidadeMedida.requestFocus(); return false; }
         */
        return true;

    }
    private void buscar(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_buscar
        buscarTodos();
    }//GEN-LAST:event_buscar

    private void buscarTodos() {
        /*
         * // Carrega todos os dados da tabela Familia List<Material> lista =
         * new MaterialDAO().findAll();
         *
         * DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
         * modelo.setNumRows(0);
         *
         *
         *
         * for (Material mat : lista) { modelo.addRow(new
         * String[]{mat.getMat_classe().getCla_id() +
         * mat.getMat_familia().getFam_id() + mat.getMat_identificador() + "-" +
         * mat.getMat_digitoVerificador() + "", "" +
         * mat.getMat_classe().getCla_descricao(),
         * mat.getMat_familia().getFam_descricao(), mat.getMat_descricao(),
         * mat.getMat_unidadeMedida().getUnm_descricao()}); }
         */
    }

    private String formatarData(Date data) {
        String data_formatado = null;
        if (data != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            data_formatado = sdf.format(data);
            System.out.println("data intput- >" + data.toString());
            System.out.println("data output- >" + data_formatado);
        }
        return data_formatado;
    }

    private void efetuarCalculos() {
        float largura;
        float comprimento;
        float perimetro;
        float area;

        largura = Float.parseFloat(tbLargura.getText().replace(',', '.'));
        comprimento = Float.parseFloat(tbComprimento.getText().replace(',', '.'));

        perimetro = 2 * largura + 2 * comprimento;
        area = largura * comprimento;

        tbPerimetro.setText((perimetro + "").replace('.', ',') + " m ");
        tbArea.setText((area + "").replace('.', ',') + " m² ");


    }

    private void carregarCamposPeloID(int id) {
        System.out.println("CARREGAR CAMPOS PELO ID ---- " + id);
        limparCampos();

        if (prodao.findById(id) == null) {
            JOptionPane.showMessageDialog(null, "Registro inexistente!");
        } else {
            pro = new Projeto();
            pro = prodao.findById(id);
            setStatusAlterar();
            tbCodigo.setText(pro.getPro_id() + "");
            tbDataProjeto.setText(formatarData(pro.getDataCadastroProjeto()));
            System.out.println("Data inicio prevista -> " + pro.getPro_dataInicioPrevista());
            tbDataInicioPrev.setText(formatarData(pro.getPro_dataInicioPrevista()));

            tbCliente.setText(pro.getCliente().getNomeCompleto() + "");
            tbCPF.setText(pro.getCliente().getCpf_cnpj());
            tbEnderecoCliente.setText(pro.getCliente().getEndereco());

            tbDataFimPrev.setText(formatarData(pro.getPro_dataFimPrevista()));
            System.out.println("Data conclusao prevista -> " + formatarData(pro.getPro_dataFimPrevista()));

            System.out.println("Data fim prev-> " + pro.getPro_dataFimPrevista());
            if (pro.getPro_dataEncerra() != null) {
                System.out.println("Data encerra-> " + pro.getPro_dataEncerra());
                tbDataConclusao.setText(formatarData(pro.getPro_dataEncerra()));
                tbDataEncerraTab4.setText(formatarData(pro.getPro_dataEncerra()));
                ctMotivoEncerra.setText(pro.getPro_obsEncerra());
                tbNomeUsuarioFim.setText(pro.getPro_usuarioEncerra());
            }
            if (pro.getPro_dataInicio() != null) {
                System.out.println("Data inicio ------> " + pro.getPro_dataInicio());
                tbDataInicio.setText(formatarData(pro.getPro_dataInicio()));
                tbDataInicioTab4.setText(formatarData(pro.getPro_dataInicio()));
                ctObsInicio.setText(pro.getPro_obsInicio());
                tbNomeUsuarioInicio.setText(pro.getPro_usuarioInicio());
            }

            if (pro.getProjetoPrincipal() != null) {
                lbCodigoProjetoPrincipal.setText(pro.getProjetoPrincipal().getPro_id() + "");
                lbProjetoPrincipal.setText("Complemento do projeto: ");
                TabDimensoes.setEnabledAt(4, false);
                btnCriarComplemento.setEnabled(false);
            } else {
                lbCodigoProjetoPrincipal.setText("");
                lbProjetoPrincipal.setText("Projeto Principal");
                TabDimensoes.setEnabledAt(4, true);
                btnCriarComplemento.setEnabled(true);
            }
            
            String situacao = "Erro";
            switch (pro.getPro_status()) {
                case -1:
                    btnReativar.setEnabled(true);
                    btnConcluirConstr.setEnabled(false);
                    btnIniciarConstr.setEnabled(false);
                    btnCriarComplemento.setEnabled(false);
                    btnImprimir.setEnabled(false);
                    situacao = "Excluído";
                    break;
                case 0:
                    btnReativar.setEnabled(false);
                    btnConcluirConstr.setEnabled(false);
                    btnCriarComplemento.setEnabled(false);
                    btnIniciarConstr.setEnabled(true);
                    btnImprimir.setEnabled(true);
                    situacao = "Aberto";
                    break;
                case 1:
                    btnReativar.setEnabled(false);
                    btnIniciarConstr.setEnabled(false);
                    btnCriarComplemento.setEnabled(false);
                    btnConcluirConstr.setEnabled(true);
                    btnImprimir.setEnabled(true);
                    situacao = "Em construção";
                    break;
                case 2:
                    btnReativar.setEnabled(false);
                    btnConcluirConstr.setEnabled(false);
                    btnIniciarConstr.setEnabled(false);
                    btnCriarComplemento.setEnabled(true);                    
                    btnImprimir.setEnabled(true);
                    situacao = "Concluído";
                    break;
            }
            tbStatus.setText(situacao);


            
            tbLogradouroInst.setText(pro.getPro_logradouroInst() + "");
            tbBairroInst.setText(pro.getPro_bairroInst() + "");
            tbCepInst.setText(pro.getPro_cepinst() + "");
            
            
            tbCodigoCidade.setText(pro.getPro_cidadeInst().getCidade_id());
            System.out.println(" GEt ID cidade - Carregar Campos ID -> "+pro.getPro_cidadeInst().getCidade_id());
            pro.setPro_cidadeInst(cidadedao.findById(pro.getPro_cidadeInst().getCidade_id()));
            
            tbCidadeInst.setText(pro.getPro_cidadeInst().getCidade_descricao());
            System.out.println(" GEt descricao cidade - Carregar Campos ID -> "+pro.getPro_cidadeInst().getCidade_descricao());
            tbEstadoConstr.setText(pro.getPro_estadoInst().getEstado_descricao());
            System.out.println(" GEt descricao estado - Carregar Campos ID -> "+pro.getPro_estadoInst());
            tbPaisConstr.setText(pro.getPro_paisInst().getPais_descricao());
            System.out.println(" GEt descricao pais - Carregar Campos ID -> "+pro.getPro_paisInst());

            tbComplementoInst.setText(pro.getPro_complementoInst() + "");

            ctDescricao.setText(pro.getPro_descricao() + "");
            ctMotivoEncerra.setText(pro.getPro_obsEncerra());

            tbAltura.setText(pro.getPro_altura() + "");
            tbLargura.setText(pro.getPro_largura() + "");
            tbComprimento.setText(pro.getPro_comprimento() + "");
            tbValorTotal.setText(pro.getPro_valorTotal() + "");

            tbAltura.setText(tbAltura.getText().replace('.', ','));
            tbLargura.setText(tbLargura.getText().replace('.', ','));
            tbComprimento.setText(tbComprimento.getText().replace('.', ','));
            tbValorTotal.setText(tbValorTotal.getText().replace('.', ','));

            

            carregarMateriaisDoProjeto(pro);
            carregarImagensDoProjeto(pro);
            carregarComplementosDoProjeto(pro);
            efetuarCalculos();

        }
    }

    private void ctDescricaoKeyPressed(java.awt.event.KeyEvent evt) {
        if (evt.getKeyCode() == KeyEvent.VK_TAB) {
            tbCPF.requestFocus();
        }
    }

    private void carregarMateriaisDoProjeto(Projeto projeto) {

        List<MaterialDoProjeto> lista = new MaterialDoProjetoDAO().findMateriaisDoProjeto(projeto);
        DefaultTableModel modelo = (DefaultTableModel) jTable2.getModel();
        modelo.setNumRows(0);

        for (MaterialDoProjeto m : lista) {

            modelo.addRow(new String[]{"" + m.getMaterialComponente().getMat_codigoCompleto(), m.getMaterialComponente().getMat_descricao(), m.getMaterialComponente().getMat_classe().getCla_descricao(), m.getMaterialComponente().getMat_familia().getFam_descricao(), m.getQuantidade() + "", m.getMaterialComponente().getMat_unidadeMedida().getUnm_sigla()});
        }
    }

    private void carregarImagensDoProjeto(Projeto projeto) {

        List<ImagemDoProjeto> lista = new ImagemDoProjetoDAO().findImagensDoProjeto(projeto);
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        modelo.setNumRows(0);

        for (ImagemDoProjeto m : lista) {
            modelo.addRow(new String[]{"" + m.getNome_imagem(), "" + m.getDescricao_imagem(), m.getCaminho_imagem()});
        }
    }

    private void carregarComplementosDoProjeto(Projeto projeto) {

        List<Projeto> lista = new ProjetoDAO().findComplementos(projeto);
        DefaultTableModel modelo = (DefaultTableModel) jTable3.getModel();
        modelo.setNumRows(0);
        if (!lista.isEmpty()) {
            for (Projeto m : lista) {
                String situacao = "Erro";

                switch (m.getPro_status()) {
                    case -1:
                        situacao = "Excluído";
                        break;
                    case 0:
                        situacao = "Aberto";
                        break;
                    case 1:
                        situacao = "Em construção";
                        break;
                    case 2:
                        situacao = "Concluído";
                        break;
                }
                modelo.addRow(new String[]{"" + m.getPro_id(), "" + m.getDataCadastroProjeto(), m.getPro_descricao(), situacao});
            }
        }
    }
    private void btnExlcuirProjetoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExlcuirProjetoActionPerformed
        int opt = JOptionPane.showConfirmDialog(null, "Deseja excluir este projeto? ");
        if (opt == 0) {
            pro.setPro_status(-1);
            prodao.update(pro);
            limparCampos();
            setStatusInicial();
        }
    }//GEN-LAST:event_btnExlcuirProjetoActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        limparCampos();
        buscarTodos();
        setStatusInicial();
        tbCodigo.requestFocus();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void tbEnderecoClienteActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void ctDescricaoKeyReleased(java.awt.event.KeyEvent evt) {
    }

    private void ctDescricaoKeyTyped(java.awt.event.KeyEvent evt) {
        if (evt.getKeyCode() == KeyEvent.VK_TAB) {
            tbCPF.requestFocus();
        }
    }
    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed

        switch (status) {
            case 'I': // Status de  Inserir

                pro = new Projeto();

                try {
                    pro.setDataCadastroProjeto(
                            new SimpleDateFormat("dd/MM/yyyy").parse(
                            tbDataProjeto.getText()));
                } catch (ParseException f) {
                    System.out.println("" + f.getMessage());
                }

                if (tbCPF.getText().length() == 11) {
                    System.out.println("Pessoa Física");
                    cli.setTipoPessoa(0);
                } else if (tbCPF.getText().length() == 14) {
                    System.out.println("Pessoa Jurídica");
                    cli.setTipoPessoa(1);
                } else {
                    System.out.println("Estrangeiro");
                    cli.setTipoPessoa(2);
                }

                cli.setCpf_cnpj(tbCPF.getText());
                pro.setCliente(cli);
                pro.setPro_bairroInst(tbBairroInst.getText());
                System.out.println("CEP- > " + tbCepInst.getText().substring(0, 2) + " " + tbCepInst.getText().substring(3, 6) + " " + tbCepInst.getText().substring(7, 10));
                pro.setPro_cepinst(Integer.parseInt(tbCepInst.getText().substring(0, 2) + tbCepInst.getText().substring(3, 6) + tbCepInst.getText().substring(7, 10)));
                System.out.println("set id" + tbCodigoCidade.getText());
                cidade = new LocalizaCidade();
                cidade.setCidade_id(tbCodigoCidade.getText());
                System.out.println("set id setter");
                pro.setPro_cidadeInst(cidade);
                System.out.println("Cidade atrib");

                pro.setPro_complementoInst(tbComplementoInst.getText());

                try {
                    pro.setPro_dataInicioPrevista(
                            new SimpleDateFormat("dd/MM/yyyy").parse(
                            tbDataInicioPrev.getText()));
                } catch (ParseException f) {
                    System.out.println("" + f.getMessage());
                }
                try {
                    pro.setPro_dataFimPrevista(
                            new SimpleDateFormat("dd/MM/yyyy").parse(
                            tbDataFimPrev.getText()));
                } catch (ParseException f) {
                    System.out.println("" + f.getMessage());
                }
                pro.setPro_descricao(ctDescricao.getText());
                pro.setPro_logradouroInst(tbLogradouroInst.getText());

                pro.setPro_altura(Float.parseFloat(tbAltura.getText().replace(',', '.')));
                pro.setPro_largura(Float.parseFloat(tbLargura.getText().replace(',', '.')));
                pro.setPro_comprimento(Float.parseFloat(tbComprimento.getText().replace(',', '.')));
                pro.setPro_valorTotal(Float.parseFloat(tbValorTotal.getText().replace(',', '.')));

                pro.setPro_obsEncerra(ctMotivoEncerra.getText());
                pro.setPro_obsInicio(ctObsInicio.getText());
                pro.setPro_status(0);// status de aberto                 

                System.out.println("Dados principais OK");

                if (!lbCodigoProjetoPrincipal.getText().trim().isEmpty()) {
                    pro.setProjetoPrincipal(new ProjetoDAO().findById(Integer.parseInt(lbCodigoProjetoPrincipal.getText())));
                }
                // O retorno do verifica  campos nulos é TRUE ou FALSE - dá pra usar direto no IF
                if (verificaCamposNulos()) {

                    prodao.insert(pro);
                    System.out.println("commit projeto principal");
                    // Gravar materiais do projeto
                    for (int i = 0; i < jTable2.getRowCount(); i++) {

                        mp = new MaterialDoProjeto();
                        System.out.println("linha da tabela -> " + i);
                        System.out.println("contagem de linhas -> " + jTable2.getRowCount());

                        Material mc = new Material();
                        mc.setMat_codigoCompleto(jTable2.getValueAt(i, 0).toString());

                        System.out.println("Codigo completo produto componente: GetValue " + jTable2.getValueAt(i, 0).toString());

                        mp.setMaterialComponente(mc);
                        mp.setProjeto(pro);
                        mp.setQuantidade(Integer.parseInt(jTable2.getValueAt(i, 4).toString()));

                        mprdao.insert(mp);
                        System.out.println("Insert mp componente");
                    }
                    mprdao.Commit();
                    System.out.println("commit mat princ");

                    // Gravar Imagens do projeto

                    imp = new ImagemDoProjeto();
                    impdao = new ImagemDoProjetoDAO();
                    for (int i = 0; i < jTable1.getRowCount(); i++) {

                        System.out.println("linha da tabela -> " + i);
                        System.out.println("contagem de linhas -> " + jTable1.getRowCount());

                        imp.setNome_imagem(jTable1.getModel().getValueAt(i, 0) + "");
                        imp.setDescricao_imagem(jTable1.getModel().getValueAt(i, 1) + "");
                        imp.setCaminho_imagem(jTable1.getModel().getValueAt(i, 2) + "");

                        imp.setProjeto(pro);
                        impdao.insert(imp);

                        System.out.println("Insert imagem projeto ");
                    }
                    impdao.Commit();
                    System.out.println("commit imagem princ");


                    JOptionPane.showMessageDialog(null, "Projeto cadastrado com sucesso!");
                    limparCampos();
                    setStatusInicial();
                }
                break;
            case 'A': // Status de Alterar

                try {
                    pro.setDataCadastroProjeto(
                            new SimpleDateFormat("dd/MM/yyyy").parse(
                            tbDataProjeto.getText()));
                } catch (ParseException f) {
                    System.out.println("" + f.getMessage());
                }
                cli.setCpf_cnpj(tbCPF.getText());
                pro.setCliente(cli);
                pro.setPro_bairroInst(tbBairroInst.getText());
                System.out.println("CEP- > " + tbCepInst.getText().substring(0, 2) + " " + tbCepInst.getText().substring(3, 6) + " " + tbCepInst.getText().substring(7, 10));
                pro.setPro_cepinst(Integer.parseInt(tbCepInst.getText().substring(0, 2) + tbCepInst.getText().substring(3, 6) + tbCepInst.getText().substring(7, 10)));
                
                cidade = new LocalizaCidade();
                cidade.setCidade_id(tbCodigoCidade.getText());
                System.out.println("set id setter");
                pro.setPro_cidadeInst(cidade);
                System.out.println("Cidade atrib");
                
                pro.setPro_complementoInst(tbComplementoInst.getText());
                try {
                    pro.setPro_dataInicioPrevista(
                            new SimpleDateFormat("dd/MM/yyyy").parse(
                            tbDataInicioPrev.getText()));
                } catch (ParseException f) {
                    System.out.println("" + f.getMessage());
                }
                try {
                    pro.setPro_dataFimPrevista(
                            new SimpleDateFormat("dd/MM/yyyy").parse(
                            tbDataFimPrev.getText()));
                } catch (ParseException f) {
                    System.out.println("" + f.getMessage());
                }
                pro.setPro_descricao(ctDescricao.getText());
                pro.setPro_logradouroInst(tbLogradouroInst.getText());

                if (!"  /  /    ".equals(tbDataEncerraTab4.getText())) {
                    try {
                        pro.setPro_dataEncerra(
                                new SimpleDateFormat("dd/MM/yyyy").parse(
                                tbDataEncerraTab4.getText()));
                    } catch (ParseException f) {
                        System.out.println("" + f.getMessage());
                    }
                    pro.setPro_obsEncerra(ctMotivoEncerra.getText());
                    pro.setPro_usuarioEncerra(Login.getNome());
                }
                if (!"  /  /    ".equals(tbDataInicioTab4.getText())) {
                    try {
                        pro.setPro_dataInicio(
                                new SimpleDateFormat("dd/MM/yyyy").parse(
                                tbDataInicioTab4.getText()));
                    } catch (ParseException f) {
                        System.out.println("" + f.getMessage());
                    }
                    pro.setPro_usuarioInicio(Login.getNome());
                }
                

                /*
                 * ATUALIZA OS MATERIAIS DO PROJETO
                 */
                mprdao.deleteMateriaisDoProjeto(pro);
                mprdao = new MaterialDoProjetoDAO();
                mp = new MaterialDoProjeto();

                for (int i = 0; i < jTable2.getRowCount(); i++) {

                    mp = new MaterialDoProjeto();
                    System.out.println("linha da tabela -> " + i);
                    System.out.println("contagem de linhas -> " + jTable2.getRowCount());

                    Material mc = new Material();
                    mc.setMat_codigoCompleto(jTable2.getValueAt(i, 0).toString());

                    System.out.println("Codigo completo produto componente: GetValue " + jTable2.getValueAt(i, 0).toString());

                    mp.setMaterialComponente(mc);
                    mp.setProjeto(pro);
                    mp.setQuantidade(Integer.parseInt(jTable2.getValueAt(i, 4).toString()));

                    mprdao.insert(mp);
                    System.out.println("Insert mp componente");
                }
                /*
                 * ATUALIZA AS IMAGENS DO PROJETO
                 */
                impdao = new ImagemDoProjetoDAO();
                impdao.deleteImagensDoProjeto(pro);
                imp = new ImagemDoProjeto();

                for (int i = 0; i < jTable1.getRowCount(); i++) {

                    System.out.println("linha da tabela -> " + i);
                    System.out.println("contagem de linhas -> " + jTable1.getRowCount());

                    imp.setNome_imagem(jTable1.getModel().getValueAt(i, 0) + "");
                    imp.setDescricao_imagem(jTable1.getModel().getValueAt(i, 1) + "");
                    imp.setCaminho_imagem(jTable1.getModel().getValueAt(i, 2) + "");

                    imp.setProjeto(pro);
                    impdao.insert(imp);

                    System.out.println("Insert imagem projeto ");
                }
                impdao.Commit();
                System.out.println("commit imagem princ");

                pro.setPro_obsEncerra(ctMotivoEncerra.getText());
                pro.setPro_obsInicio(ctObsInicio.getText());

                pro.setPro_altura(Float.parseFloat(tbAltura.getText().replace(',', '.')));
                pro.setPro_largura(Float.parseFloat(tbLargura.getText().replace(',', '.')));
                pro.setPro_comprimento(Float.parseFloat(tbComprimento.getText().replace(',', '.')));
                pro.setPro_valorTotal(Float.parseFloat(tbValorTotal.getText().replace(',', '.')));

                prodao.update(pro);
                buscarTodos();
                limparCampos();
                setStatusInicial();
                break;

        }


    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnAddImagemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddImagemActionPerformed

        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        imp.setNome_imagem(tbNomeImagem.getText());
        imp.setCaminho_imagem(tbEnderecoImg.getText());
        imp.setDescricao_imagem(tbDescricaoImagem.getText());

        modelo.addRow(new String[]{"" + imp.getNome_imagem(), "" + imp.getDescricao_imagem(), imp.getCaminho_imagem()});
        tbNomeImagem.setText("");
        tbEnderecoImg.setText("");
        tbDescricaoImagem.setText("");
        carregarImagem(tbEnderecoImg.getText());
    }//GEN-LAST:event_btnAddImagemActionPerformed

    private void jTable1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyTyped
        System.out.println("Get here -");
        int selectedRow = jTable1.getSelectedRow();
        carregarImagem(jTable1.getModel().getValueAt(selectedRow, 2) + "");
        carregarCamposImagem(selectedRow);
    }//GEN-LAST:event_jTable1KeyTyped

    private void jTable1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyReleased

        int selectedRow = jTable1.getSelectedRow();
        carregarImagem(jTable1.getModel().getValueAt(selectedRow, 2) + "");
        carregarCamposImagem(selectedRow);
    }//GEN-LAST:event_jTable1KeyReleased

    private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed
   }//GEN-LAST:event_jTable1KeyPressed

    private void jTable1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MousePressed
        int selectedRow = jTable1.getSelectedRow();
        carregarImagem(jTable1.getModel().getValueAt(selectedRow, 2) + "");
        carregarCamposImagem(selectedRow);
    }//GEN-LAST:event_jTable1MousePressed

    private void btnImagemFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_btnImagemFocusLost
   }//GEN-LAST:event_btnImagemFocusLost

    private void btnImagemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImagemActionPerformed

        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle("Selecione uma imagem");
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        //
        // disable the "All files" option.
        //
        chooser.setAcceptAllFileFilterUsed(false);
        //    
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            System.out.println("getCurrentDirectory(): "
                    + chooser.getCurrentDirectory());
            System.out.println("getSelectedFile() : "
                    + chooser.getSelectedFile());
        } else {
            System.out.println("No Selection ");
        }
        carregarImagem(chooser.getSelectedFile() + "");
    }//GEN-LAST:event_btnImagemActionPerformed

    private void tbEnderecoImgFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbEnderecoImgFocusLost
        carregarImagem(tbEnderecoImg.getText());
    }//GEN-LAST:event_tbEnderecoImgFocusLost

    private void btnAddProdutosKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnAddProdutosKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAddProdutosKeyTyped

    private void btnAddProdutosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnAddProdutosKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAddProdutosKeyPressed

    private void btnAddProdutosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_btnAddProdutosFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAddProdutosFocusLost

    private void btnAddProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddProdutosActionPerformed
        MaterialDialog popup = new MaterialDialog(this, true);
        popup.setVisible(true);

        Material m = new Material();
        m = popup.getMaterialComponente();

        System.out.println("AQUIIII!");
        DefaultTableModel modelo = (DefaultTableModel) jTable2.getModel();

        modelo.addRow(new String[]{"" + m.getMat_codigoCompleto(), m.getMat_descricao(), m.getMat_classe().getCla_descricao(), m.getMat_familia().getFam_descricao(),1 + "",  m.getMat_unidadeMedida().getUnm_sigla()});

        popup.dispose();
    }//GEN-LAST:event_btnAddProdutosActionPerformed

    private void btnExlcuirProdutoComp1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExlcuirProdutoComp1ActionPerformed
        int selecionada = jTable2.getSelectedRow();
        // obtem o valor da coluna
        String codigo = (String) jTable2.getValueAt(selecionada, 0);

        DefaultTableModel model = (DefaultTableModel) jTable2.getModel();
        model.removeRow(jTable2.getSelectedRow());
        jTable2.setModel(model);
    }//GEN-LAST:event_btnExlcuirProdutoComp1ActionPerformed

    private void btnCriarComplementoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCriarComplementoActionPerformed
        status = 'I';
        setStatusInicial();
        tbCodigo.setText("Novo Registro");
        tbCodigo.setEnabled(false);
        tbDataProjeto.requestFocus();
        lbCodigoProjetoPrincipal.setText(pro.getPro_id() + "");
        lbProjetoPrincipal.setText("Complemento do projeto: ");
        ctDescricao.setText("Complemento do projeto "+pro.getPro_id());
        
        tbAltura.setText("");
        tbLargura.setText("");
        tbComprimento.setText("");
        
        tbValorTotal.setText("");
        tbPerimetro.setText("");
        tbArea.setText("");
        
/*        DefaultTableModel dtm = new DefaultTableModel();
        dtm.setRowCount(0);        
        jTable2.setModel(dtm);*/

    }//GEN-LAST:event_btnCriarComplementoActionPerformed

    private void btnCopiarProjetoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCopiarProjetoActionPerformed
        status = 'I';
        setStatusInicial();
        tbCodigo.setText("Novo Registro");
        tbCodigo.setEnabled(false);
        tbDataProjeto.requestFocus();
        pro= new Projeto();
    }//GEN-LAST:event_btnCopiarProjetoActionPerformed

    private void btnConcluirConstrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConcluirConstrActionPerformed
        ConcluirConstrucaoDialog popup = new ConcluirConstrucaoDialog(null, true, pro);
        popup.setVisible(true);

        String date = popup.getDataConclusaoFormatada();
        String obs = popup.getObs();

        tbDataConclusao.setText(date);
        tbDataEncerraTab4.setText(date);
        ctMotivoEncerra.setText(obs);

        if (!date.isEmpty()) {
            pro.setPro_status(2);
        }
//          prodao.update(m);
        popup.dispose();
    }//GEN-LAST:event_btnConcluirConstrActionPerformed

    private void btnIniciarConstrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIniciarConstrActionPerformed
        IniciarConstrucaoDialog popup = new IniciarConstrucaoDialog(null, true, pro);
        popup.setVisible(true);

        String date = popup.getDataInicioFormatada();
        tbDataInicio.setText(date);
        ctObsInicio.setText(popup.getObsInicio());
        tbDataInicioTab4.setText(date);
        
        pro.setPro_status(1);
        popup.dispose();
    }//GEN-LAST:event_btnIniciarConstrActionPerformed

    private void btnCopiarEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCopiarEndActionPerformed
        tbLogradouroInst.setText(cli.getLogradouro());
        tbComplementoInst.setText(cli.getComplemento());
        tbBairroInst.setText(cli.getBairro());
        tbCepInst.setText(cli.getCep() + "");
        tbCodigoCidade.setText(cli.getCidade().getCidade_id() + "");
        tbCidadeInst.setText(cli.getCidade().getCidade_descricao());
        tbEstadoConstr.setText(cli.getCidade().getEstado_cidade().getEstado_descricao());
        tbPaisConstr.setText(cli.getCidade().getEstado_cidade().getPais_estado().getPais_descricao());
        
        
        
   }//GEN-LAST:event_btnCopiarEndActionPerformed

    private void tbCidadeInstFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbCidadeInstFocusLost
        tbLargura.requestFocus();
        TabDimensoes.setSelectedIndex(1);
    }//GEN-LAST:event_tbCidadeInstFocusLost

    private void tbCepInstFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbCepInstFocusLost
   }//GEN-LAST:event_tbCepInstFocusLost

    private void tbCodigoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbCodigoKeyTyped
   }//GEN-LAST:event_tbCodigoKeyTyped
    private void tbCodigoKeyPressed(java.awt.event.KeyEvent evt) {
        if (evt.getKeyCode() == KeyEvent.VK_F2) {
            ProjetoDialog popup = new ProjetoDialog(null, true);

            popup.setVisible(true);

            Projeto m = popup.getProjeto();
            System.out.println(" ID do -> " + m.getPro_id());
            if (m.getPro_id() != 0) {
                System.out.println("AQUIIII!");
                carregarCamposPeloID(m.getPro_id());
            } else {
                setStatusInicial();
                tbCodigo.setText("");
            }
            popup.dispose();
        }

    }

    private void tbCodigoFocusLost(java.awt.event.FocusEvent evt) {
        
        if (tbCodigo.getText().isEmpty()) {
            tbCodigo.setText("Novo Registro");
            tbDataProjeto.requestFocus();
        } else {
            carregarCamposPeloID(Integer.parseInt(tbCodigo.getText()));
            tbDataProjeto.requestFocus();
        }
        tbCodigo.setEnabled(false);
    }
//GEN-FIRST:event_tbCodigoKeyPressed
//GEN-LAST:event_tbCodigoKeyPressed
    private void tbCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbCodigoActionPerformed
    }//GEN-LAST:event_tbCodigoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        efetuarCalculos();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void tbCPFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbCPFFocusLost
        btnCopiarEnd.setEnabled(true);
    }//GEN-LAST:event_tbCPFFocusLost

    private void tbCPFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbCPFKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_F2) {
            ClientesDialog popup = new ClientesDialog(null, false);
            popup.setVisible(true);

            Cliente m = popup.getCliente();
            System.out.println(" ID do cliente selecionado do dialog -> " + m.getCpf_cnpj() + "tipopes -> " + m.getTipoPessoaDescricao());
            if (!m.getCpf_cnpj().isEmpty()) {
                System.out.println("AQUIIII!");
                tbCPF.setText(m.getCpf_cnpj());
                tbCliente.setText(m.getNomeCompleto());
                tbEnderecoCliente.setText(m.getEndereco());
                cli = m;
                pro.setCliente(cli);
            } else {
                setStatusInicial();
                tbCodigo.setText("");
            }
            popup.dispose();
        }

    }//GEN-LAST:event_tbCPFKeyPressed

    private void btnReativarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReativarActionPerformed
        if (pro.getPro_dataInicio() != null) {
            if (pro.getPro_dataEncerra() != null) {
                tbStatus.setText("Concluído");
                pro.setPro_status(2);
            } else {
                tbStatus.setText("Em construção");
                pro.setPro_status(1);
            }
        } else {
            tbStatus.setText("Aberto");
            pro.setPro_status(0);
        }
    }//GEN-LAST:event_btnReativarActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        tbCodigo.requestFocus();
    }//GEN-LAST:event_formWindowOpened

    private void btnImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirActionPerformed

        JRBeanCollectionDataSource jrs = new JRBeanCollectionDataSource(mprdao.findMateriaisDoProjeto(pro));
        // Parametros
        Map parametros = new HashMap();
        parametros.put("usuario", Login.getNome());

        try {
            // Carrega o relatório para ser executado
            JasperPrint jpr = JasperFillManager.fillReport("reports/projeto.jasper", parametros, jrs);
            // Mostra o relatório - faz o show
            JasperViewer.viewReport(jpr, false);
        } catch (JRException ex) {
            Logger.getLogger(ProjetoFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnImprimirActionPerformed

    private void jTable3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable3MouseClicked
        if (evt.getClickCount() == 2) {
            int linha = jTable3.getSelectedRow();
            carregarCamposPeloID(Integer.parseInt(jTable3.getValueAt(linha, 0).toString()));
        }
    }//GEN-LAST:event_jTable3MouseClicked

    private void tbComprimentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbComprimentoFocusLost
        efetuarCalculos();
    }//GEN-LAST:event_tbComprimentoFocusLost

    private void tbValorTotalFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbValorTotalFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_tbValorTotalFocusLost

    private void tbCodigoCidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbCodigoCidadeFocusLost
        cidadedao = new LocalizaCidadeDAO();
        cidade = cidadedao.findById(tbCodigoCidade.getText());
        tbCidadeInst.setText(cidade.getCidade_descricao());
        tbEstadoConstr.setText(cidade.getEstado_cidade().getEstado_descricao());
        tbPaisConstr.setText(cidade.getEstado_cidade().getPais_estado().getPais_descricao());
    }//GEN-LAST:event_tbCodigoCidadeFocusLost

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        System.exit(1);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed

   }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        ProjetoFrame cf = new ProjetoFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        System.exit(1);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        LocalizaFrame cf = new LocalizaFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        MaterialFrameTab1 cf = new MaterialFrameTab1();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        FamiliaFrame cf = new FamiliaFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        ClasseFrame cf = new ClasseFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
        UsuarioFrame cf = new UsuarioFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        ClienteFrame cf = new ClienteFrame();
        cf.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void tbCodigoCidadeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbCodigoCidadeKeyPressed
       if (evt.getKeyCode() == KeyEvent.VK_F2) {
            CidadeDialog popup = new CidadeDialog(null, true);

            popup.setVisible(true);

            LocalizaCidade m = popup.getCidade();
            System.out.println(" ID cidade -> " + m.getCidade_id());
            if (!m.getCidade_id().trim().isEmpty()) {
                tbCodigoCidade.setText(""+m.getCidade_id());
                tbCidadeInst.setText(""+m.getCidade_descricao());
                tbEstadoConstr.setText(""+m.getEstado_cidade().getEstado_descricao());
                tbPaisConstr.setText(m.getEstado_cidade().getPais_estado().getPais_descricao());
            } else {
                setStatusInicial();
                tbCodigoCidade.setText("");
                tbCliente.setText("");
                tbEstadoConstr.setText("");
                tbPaisConstr.setText("");                
            }
            popup.dispose();
        }
    }//GEN-LAST:event_tbCodigoCidadeKeyPressed

    private void carregarCamposImagem(int linhaTabela) {
        tbNomeImagem.setText(jTable1.getModel().getValueAt(linhaTabela, 0) + "");
        tbDescricaoImagem.setText(jTable1.getModel().getValueAt(linhaTabela, 1) + "");
        tbEnderecoImg.setText(jTable1.getModel().getValueAt(linhaTabela, 2) + "");
    }

    private void carregarImagem(String diretorio) {

        ImageIcon im = new ImageIcon();
        if (!diretorio.isEmpty()) {
            im = (new javax.swing.ImageIcon(diretorio));
            java.awt.Image i = im.getImage();
            i = i.getScaledInstance(lbFoto.getWidth(), lbFoto.getHeight(), 0);
            //lbFoto.setIcon(new javax.swing.ImageIcon(chooser.getSelectedFile()+"")); // NOI18N 
            im.setImage(i);
            tbEnderecoImg.setText(diretorio);
        }
        lbFoto.setIcon(im);
    }

    private String getNumerosCPF(String cpfComMascara) {
        System.out.println("CPF com máscara INPUT -> " + cpfComMascara);
        System.out.println("CPF sem máscara OUTPUT -> " + cpfComMascara.substring(0, 3) + cpfComMascara.substring(4, 7) + cpfComMascara.substring(8, 11) + cpfComMascara.substring(12, 14));
        return (cpfComMascara.substring(0, 3) + cpfComMascara.substring(4, 7) + cpfComMascara.substring(8, 11) + cpfComMascara.substring(12, 14));
    }

    private String getNumerosCNPJ(String cnpjComMascara) {
        System.out.println("CNPJ com máscara INPUT -> " + cnpjComMascara);
        System.out.println("CNPJ sem máscara OUTPUT -> " + cnpjComMascara.substring(0, 2) + cnpjComMascara.substring(3, 6) + cnpjComMascara.substring(7, 10) + cnpjComMascara.substring(11, 15) + cnpjComMascara.substring(16, 18));
        return (cnpjComMascara.substring(0, 2) + cnpjComMascara.substring(3, 6) + cnpjComMascara.substring(7, 10) + cnpjComMascara.substring(11, 15) + cnpjComMascara.substring(16, 18));
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */

        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MaterialFrameTab1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MaterialFrameTab1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MaterialFrameTab1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MaterialFrameTab1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ProjetoFrame().setVisible(true);
            }
        });
    }
    private LocalizaCidade cidade= new LocalizaCidade();
    private LocalizaCidadeDAO cidadedao = new LocalizaCidadeDAO();
    private char status = 'I'; /*
     * I -> Inserir A -> Alterar D-> DELETAR INTERVALO
     */

    private ImagemDoProjeto imp = new ImagemDoProjeto();
    private ImagemDoProjetoDAO impdao = new ImagemDoProjetoDAO();
    private MaterialDoProjeto mp = new MaterialDoProjeto();
    private MaterialDoProjetoDAO mprdao = new MaterialDoProjetoDAO();
    private Projeto pro = new Projeto();
    private ProjetoDAO prodao = new ProjetoDAO();
    private Cliente cli = new Cliente();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu Relatório;
    private javax.swing.JTabbedPane TabDimensoes;
    private javax.swing.JButton btnAddImagem;
    private javax.swing.JButton btnAddProdutos;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConcluirConstr;
    private javax.swing.JButton btnCopiarEnd;
    private javax.swing.JButton btnCopiarProjeto;
    private javax.swing.JButton btnCriarComplemento;
    private javax.swing.JButton btnExlcuirProdutoComp1;
    private javax.swing.JButton btnExlcuirProjeto;
    private javax.swing.JButton btnImagem;
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnIniciarConstr;
    private javax.swing.JButton btnReativar;
    private javax.swing.JButton btnSalvar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextArea ctDescricao;
    private javax.swing.JTextArea ctMotivoEncerra;
    private javax.swing.JTextArea ctObsInicio;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPanelEncerramento;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JLabel lbCodigoProjetoPrincipal;
    private javax.swing.JLabel lbFoto;
    private javax.swing.JLabel lbProjetoPrincipal;
    private javax.swing.JFormattedTextField tbAltura;
    private javax.swing.JTextField tbArea;
    private javax.swing.JTextField tbBairroInst;
    private javax.swing.JTextField tbCPF;
    private javax.swing.JFormattedTextField tbCepInst;
    private javax.swing.JTextField tbCidadeInst;
    private javax.swing.JTextField tbCliente;
    private javax.swing.JTextField tbCodigo;
    private javax.swing.JTextField tbCodigoCidade;
    private javax.swing.JTextField tbComplementoInst;
    private javax.swing.JFormattedTextField tbComprimento;
    private javax.swing.JFormattedTextField tbDataConclusao;
    private javax.swing.JFormattedTextField tbDataEncerraTab4;
    private javax.swing.JFormattedTextField tbDataFimPrev;
    private javax.swing.JFormattedTextField tbDataInicio;
    private javax.swing.JFormattedTextField tbDataInicioPrev;
    private javax.swing.JFormattedTextField tbDataInicioTab4;
    private javax.swing.JFormattedTextField tbDataProjeto;
    private javax.swing.JTextField tbDescricaoImagem;
    private javax.swing.JTextField tbEnderecoCliente;
    private javax.swing.JTextField tbEnderecoImg;
    private javax.swing.JTextField tbEstadoConstr;
    private javax.swing.JFormattedTextField tbLargura;
    private javax.swing.JTextField tbLogradouroInst;
    private javax.swing.JTextField tbNomeImagem;
    private javax.swing.JTextField tbNomeUsuarioFim;
    private javax.swing.JTextField tbNomeUsuarioInicio;
    private javax.swing.JTextField tbPaisConstr;
    private javax.swing.JTextField tbPerimetro;
    private javax.swing.JTextField tbStatus;
    private javax.swing.JFormattedTextField tbValorTotal;
    // End of variables declaration//GEN-END:variables
}
